package ru.onlinestore.mobile.ui.authentication.authorization

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import ru.onlinestore.mobile.ui.components.ButtonCompose
import ru.onlinestore.mobile.ui.components.ButtonText
import ru.onlinestore.mobile.ui.components.textInput

@Composable
@Preview(
    showBackground = true,
    device = "id:Xiaomi POCO M5s"
)
private fun AuthorizationScreenPreview() = AuthorizationScreen()

private val username = mutableStateOf("")
private val password = mutableStateOf("")

@Composable
fun AuthorizationScreen() {
    Column(
        modifier = Modifier
            .fillMaxSize()
            .padding(24.dp),
        content = {
            username.value = textInput(
                label = "Имя пользователя",
                keyboardType = KeyboardType.Text
            )
            password.value = textInput(
                label = "Пароль",
                keyboardType = KeyboardType.Password
            )

            ButtonText(
                text = "Ещё нету аккаунта?",
                onClick = {

                }
            )

            ButtonCompose(
                title = "Войти",
                onClick = {

                },
                fontSize = 17.sp,
                enabled = username.value.isNotEmpty() && password.value.isNotEmpty()
            )
        },
        verticalArrangement = Arrangement.spacedBy(
            space = 12.dp,
            alignment = Alignment.CenterVertically
        ),
        horizontalAlignment = Alignment.CenterHorizontally
    )
}
